/*1:输入两个字符串，查找第一个字符串在第二个字符串中出现的次数
比如输入dog和 This is a good dog.
则出现了一次。*/
package Work0524;

import java.util.Scanner;

public class CharacterString {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		System.out.println("输入第一个字符串:");
		String a = in.next();
		System.out.println("输入第二个字符串:");
		String b = in.next();
		int num = 0, c = 0;
		while (true) {
			if (b.indexOf(a, c) > -1) {
				c = b.indexOf(a, c) + a.length();
				num++;
				if (c > b.length()) {
					break;
				}
			} else {
				break;
			}
		}
		System.out.println("出现的次数为" + num);
	}

}
